import tkinter as tk


class MessageLabel:
    def __init__(self, frame):
        self.msg = tk.Text(
            frame,
            height=12,
            wrap=tk.WORD,
            font=("", 10),
            state="disabled",  # 设置为不可编辑
            padx=5,
            pady=5,
            relief=tk.FLAT,  # 去掉边框效果
            highlightthickness=0,  # 去掉高亮边框
            bg=tk.Label().cget("bg"),
        )

    def grid(self, **options):
        self.msg.grid(**options)  # 配置滚动条

    def configure(self, text):
        self.msg.config(state="normal")
        self.msg.delete("1.0", tk.END)
        self.msg.insert(tk.END, text)
        self.msg.config(state="disabled")
